package com.wdl.sm.webui.yang.type;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

import com.nokia.taiji.yang.schema.YangType.Range;
import com.nokia.taiji.yang.schema.YangType.TypeString;

public class StringValue extends NormalizedValue {
    List<String> patterns = new ArrayList<String>();

    // -1 means no limitation
    String minLength = "-1";
    String maxLength = "-1";
    
    public StringValue(TypeString input) {
        super(input);
        tag = "string";
        
        Range range = input.getLength();
        
        if (range != null) {
            minLength = String.valueOf(input.getLength().getMin());
            maxLength = String.valueOf(input.getLength().getMax());
        }

        List<Pattern> patternList = input.getPatterns();
        if (patternList == null || patternList.isEmpty()) {
            return;
        }

        for (Pattern item : patternList) {
            patterns.add(item.pattern());
        }
    }

    public List<String> getPatterns() {
        return patterns;
    }

    public void setPattern(List<String> patterns) {
        this.patterns = patterns;
    }

    public String getMinLength() {
        return minLength;
    }

    public void setMinLength(String minLength) {
        this.minLength = minLength;
    }

    public String getMaxLength() {
        return maxLength;
    }

    public void setMaxLength(String maxLength) {
        this.maxLength = maxLength;
    }
}